console.log("popup.js loaded start");

console.log("抖音插件")
$("#setPushApi").click(function () {
    let data = $("#url").val();
    if (data == "") {
        alert("请输入推送接口地址");
        return;
    }
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
        chrome.tabs.sendMessage(tabs[0].id,{
            type: "setApiUrl",
            data
        },function (response) {
            console.log(response);
            alert(response.msg);
        });
    });
});
//setSayGift
$("#setSayGift").click(function () {
    let data = $("#sayGift").val();
    if (data == "") {
        alert("请输入发送参数");
        return;
    }
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
        chrome.tabs.sendMessage(tabs[0].id,{
            type: "setSayGift",
            data
        },function (response) {
            console.log(response);
            alert(response.msg);
        });
    });
})
$("#setSayWelcome").click(function () {
    let data = $("#sayWelcome").val();
    if (data == "") {
        alert("请输入发送参数");
        return;
    }
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
        chrome.tabs.sendMessage(tabs[0].id,{
            type: "setSayWelcome",
            data
        },function (response) {
            console.log(response);
            alert(response.msg);
        });
    });
})
$("#setSendConfig").click(function () {
    let data = $("#sendConfig").val();
    if (data == "") {
        alert("请输入发送参数");
        return;
    }
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
        chrome.tabs.sendMessage(tabs[0].id,{
            type: "setSendConfig",
            data
        },function (response) {
            console.log(response);
            alert(response.msg);
        });
    });
})
console.log("popup.js loaded end");
